function V_stack = calculate_fc_voltage(I_fc, FCParams)
% =========================================================================
% calculate_fc_voltage.m - 根据PDF文档中的电化学模型计算燃料电池电堆电压
% =========================================================================

    % 从参数结构体中提取所需参数
    N_cells = FCParams.N_cells;
    T = FCParams.T;
    R_const = FCParams.R_const;
    F_const = FCParams.F_const;
    A = FCParams.A;
    i_0 = FCParams.i_0;
    i_L = FCParams.i_L;
    i_internal = FCParams.i_internal;
    alpha = FCParams.alpha;
    R_ohmic_area = FCParams.R_ohmic_area;

    % 1. 计算电流密度 i (A/cm^2)
    i = I_fc / A + 1e-6; 

    % 2. 计算最大可逆电压 (能斯特电压) E_r (单片)
    E_r = 1.2; % 假设的平衡电位 (V)

    % 3. 计算活化极化损失 V_act (单片)
    V_act = (R_const * T / (alpha * F_const)) * log((i + i_internal) / i_0);

    % 4. 计算欧姆极化损失 V_ohmic (单片)
    V_ohmic = i * R_ohmic_area;
    
    % 5. 计算浓差极化损失 V_conc (单片)
    n_electrons = 2;
    if i >= i_L
        i = i_L - 1e-6;
    end
    V_conc = (R_const * T / (n_electrons * F_const)) * log(i_L / (i_L - i));

    % 6. 计算单片电池的最终输出电压 E_cell
    E_cell = E_r - V_act - V_ohmic - V_conc;

    % 7. 计算电堆总电压 V_stack
    V_stack = E_cell * N_cells;
end
